package com.lz.ub

import android.util.Log

/**
 * @author you
 * 日志器
 */
object Logger {

    var printer: Printer = DefPrinter()

    fun v(tag: String, log: String) {
        printer.v(tag, log)
    }

    fun d(tag: String, log: String) {
        printer.d(tag, log)
    }

    fun i(tag: String, log: String) {
        printer.i(tag, log)
    }

    fun e(tag: String, log: String) {
        printer.e(tag, log)
    }

    interface Printer {

        fun v(tag: String, log: String)

        fun d(tag: String, log: String)

        fun i(tag: String, log: String)

        fun e(tag: String, log: String)
    }

    class DefPrinter(private val isDebug: Boolean = true) : Printer {

        override fun v(tag: String, log: String) {
            if (isDebug) Log.d(tag, log)
        }

        override fun d(tag: String, log: String) {
            if (isDebug) Log.d(tag, log)
        }

        override fun i(tag: String, log: String) {
            if (isDebug) Log.i(tag, log)
        }

        override fun e(tag: String, log: String) {
            if (isDebug) Log.w(tag, log)
        }
    }
}